package com.shenzhen.horselive.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.shenzhen.horselive.R;
import com.shenzhen.horselive.databinding.CashOutDialogBinding;
import com.shenzhen.horselive.databinding.DialogLoginBinding;

public class CashOutDialog extends Dialog  implements View.OnClickListener {

    public OnChooseType  onChooseType;
    public boolean  hasBank;//是否已经实名

    public boolean isHasBank() {
        return hasBank;
    }

    public CashOutDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public CashOutDialog(Context context, int theme) {
        super(context, theme);
    }

    public void setOnChooseType(OnChooseType onChooseType) {
        this.onChooseType = onChooseType;
    }

    CashOutDialogBinding   binding;
    public CashOutDialog(Context context,boolean  hasBank) {
        super(context, R.style.CommonDialog);
        //初始化
        binding = CashOutDialogBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        binding.container.setOnClickListener(this);
        binding.container1.setOnClickListener(this);
        binding.container2.setOnClickListener(this);
        this.hasBank = hasBank;
        if (hasBank)
        {
            binding.tvNoBank.setVisibility(View.GONE);
        }
        else
        {
            binding.tvNoBank.setVisibility(View.VISIBLE);
        }

    }


    public void setHasBank(boolean hasBank) {
        this.hasBank = hasBank;
        if (hasBank)
        binding.tvNoBank.setVisibility(View.GONE);
        else
        binding.tvNoBank.setVisibility(View.VISIBLE);

    }
    @Override
    public void show() {
        super.show();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width= ViewGroup.LayoutParams.MATCH_PARENT;
        layoutParams.height= ViewGroup.LayoutParams.WRAP_CONTENT;
        layoutParams.gravity = Gravity.BOTTOM;
        getWindow().setAttributes(layoutParams);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.container:
                if (onChooseType!=null)
                    onChooseType.ontype(0);
                break;
            case R.id.container1:
                if (onChooseType!=null)
                    onChooseType.ontype(1);
                break;
            case R.id.container2:
                if (onChooseType!=null)
                   onChooseType.ontype(2);
                break;
        }
        dismiss();
    }

    public  interface OnChooseType{
        void  ontype(int type);
    }

}
